
export const Request = (url,params,methods)=>{
	params=params?params:{};
	return new Promise((resolve,reject)=>{
		uni.request({
			url:`https://app.zizijy.com/api/${url}`,
			//https://testzz.numtwin.com/im/message/getChatDetails
			method:methods || 'get',
			header:{
				'Authori-zation':'Bearer '+(params && params.token?params.token:uni.getStorageSync('token') || ''),
				'Form-type':url=='v3/contract/buyContract'?'routine':null
			},
			data:params || {},
			success({data}) {
				if(data.code == 200 || data.code==0){
					resolve(data.data,data)
				}else if(data.code==0 && data.count){
					resolve(data.count)
				} else if(data.code==300){ //转登陆
					uni.redirectTo({
						url:`/logon/logon/index`
					})	
				} else{
					if(data.code == 400 && data.msg=="登录信息已失效，请重新登录!"){
						uni.setStorageSync('token','')
					}
					if(data.code == 400){
						uni.showToast({
							title:data.msg || '操作错误',
							icon:'none'
						})
					}
					
					resolve()
					reject(false)
				}
				
			},fail(err) {
				uni.hideLoading()
				reject(err)
			}
		})
	})
}